<template>
  <div class="app-container">
    <div class="top">
      <div class="left"><img src="@/assets/images/icon/leftIcon.png" alt="" srcset=""
          style="width: 15px;height: 14px;">素材库编辑</div>
      <!-- <div class="right"><el-button type="primary" size="mini" @click="handleQuery">下达</el-button> -->
    </div>
    <div>
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="120px">
        <el-form-item label="一级标题" prop="ipaddr" label-width="130px">
          <el-input v-model="topData.grandparent" placeholder="" clearable @keyup.enter.native="handleQuery"
            disabled="true" />
        </el-form-item>
        <el-form-item label="二级指标：" prop="userName">
          <el-input v-model="topData.parentName" placeholder="" clearable @keyup.enter.native="handleQuery"
            disabled="true" />
        </el-form-item>
        <el-form-item label="素材库名称：" prop="userName">
          <el-input v-model="topData.name" placeholder="素材库名称" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <!-- <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        </el-form-item> -->
      </el-form>
    </div>
    <div class="content">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="内容">
              <editor v-model="topData.content" :min-height="400" height="400" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div style=" width: 121px;margin-left: 80px;"> <el-button type="primary" size="medium " @click="updateFn"
          style="   width: 100%;" v-hasPermi="['system:material:edit']">保存</el-button></div>
    </div>
  </div>
</template>
<script>
import { updateName } from "@/api/DTotal/DTotal";
import { Message } from 'element-ui'
export default {
  name: "Online",
  data() {
    return {
      materialId: '',
      dialogFormVisible: false,
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      formLabelWidth: '120px',
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      pageNum: 1,
      pageSize: 10,
      // 查询参数
      queryParams: {
        ipaddr: undefined,
        userName: undefined
      },
      topData: {
        grandparent: '',//1级标题
        parentName: '',//2级标题
        name: '',//
        content: ''
      }
    };
  },
  created() {
    console.log(this.$route.query, 'query')
    this.topData.grandparent = this.$route.query.data.grandparent
    this.topData.parentName = this.$route.query.data.parentName
    this.topData.name = this.$route.query.data.name
    this.topData.content = this.$route.query.data.content
    this.materialId = this.$route.query.data.materialId
  },
  methods: {
    async updateFn() {
      console.log(this.topData, 'updateData')
      let data = {
        name: this.topData.name,
        materialId: this.materialId,
        content: this.topData.content
      }
      let res = await updateName(data)
      Message({ message: '保存成功', type: 'success' })
      this.$router.go(-1)
    },

  }
};
</script>
<style scoped lang="scss">
.title {
  display: flex;
  color: #A9A9AA;

  .active {
    color: #157DFA;
  }

  .step1 {
    margin-right: 10px;
  }

  span {
    margin-right: 8px;
  }
}

.top {
  display: flex;
  justify-content: space-between;
  color: #333;
  margin: 15px 0;

  .left {
    img {
      margin-right: 10px;
    }
  }

  .right {}
}
</style>
